﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>个人中心</title>
    <link rel="stylesheet" href="../../assets/libs/layui/css/layui.css" />
    <link rel="stylesheet" href="../../assets/module/admin.css?v=318" />
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        /* 用户信息 */
        .user-info-head {
            width: 110px;
            height: 110px;
            line-height: 110px;
            position: relative;
            display: inline-block;
            border: 2px solid #eee;
            border-radius: 50%;
            overflow: hidden;
            cursor: pointer;
            margin: 0 auto;
        }

            .user-info-head:hover:after {
                content: '\e681';
                position: absolute;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                color: #fff;
                background-color: rgba(0, 0, 0, 0.3);
                font-size: 28px;
                padding-top: 2px;
                font-style: normal;
                font-family: layui-icon;
                -webkit-font-smoothing: antialiased;
                -moz-osx-font-smoothing: grayscale;
            }

            .user-info-head img {
                width: 110px;
                height: 110px;
            }

        .user-info-list-item {
            position: relative;
            padding-bottom: 8px;
        }

            .user-info-list-item > .layui-icon {
                position: absolute;
            }

            .user-info-list-item > p {
                padding-left: 30px;
            }

        .layui-line-dash {
            border-bottom: 1px dashed #ccc;
            margin: 15px 0;
        }

        /* 基本信息 */
        #userInfoForm .layui-form-item {
            margin-bottom: 25px;
        }

        /* 账号绑定 */
        .user-bd-list-item {
            padding: 14px 60px 14px 10px;
            border-bottom: 1px solid #e8e8e8;
            position: relative;
        }

            .user-bd-list-item .user-bd-list-lable {
                color: #333;
                margin-bottom: 4px;
            }

            .user-bd-list-item .user-bd-list-oper {
                position: absolute;
                top: 50%;
                right: 10px;
                margin-top: -8px;
                cursor: pointer;
            }

            .user-bd-list-item .user-bd-list-img {
                width: 48px;
                height: 48px;
                line-height: 48px;
                position: absolute;
                top: 50%;
                left: 10px;
                margin-top: -24px;
            }

                .user-bd-list-item .user-bd-list-img + .user-bd-list-content {
                    margin-left: 68px;
                }
    </style>
</head>
<body>
    <!-- 正文开始 -->
    <div class="layui-fluid">
        <script id="userDataTpl" type="text/html" ew-tpl="userData">
            <div>
                <div class="layui-row layui-col-space15">
                    <!-- 左 -->
                    <div class="layui-col-sm12 layui-col-md3">
                        <div class="layui-card">
                            <div class="layui-card-body" style="padding: 25px;">
                                <div class="text-center layui-text">
                                    <div class="user-info-head" id="userInfoHead">
                                        <img src="{{d.Portrait}}" alt="" />
                                    </div>
                                    <h2 style="padding-top: 20px;">{{d.UserName}}</h2>
                                    <p style="padding-top: 8px;">海纳百川，有容乃大</p>
                                </div>
                                <div class="layui-text" style="padding-top: 30px;">
                                    <div class="user-info-list-item">
                                        <i class="layui-icon layui-icon-username"></i>
                                        <p>{{d.RealName}}</p>
                                    </div>
                                    <div class="user-info-list-item">
                                        <i class="layui-icon layui-icon-location"></i>
                                        <p>{{returnCitySN["cname"]}}</p>
                                    </div>
                                </div>
                                <div class="layui-line-dash"></div>
                                <h3>标签</h3>
                                <div class="layui-badge-list" style="padding-top: 6px;">
                                    {{# layui.each(( d.Tags ? d.Tags.split(',') : []),function(index,item){ }}
                                    <span class="layui-badge layui-bg-gray">{{item}}</span>
                                    {{# }) }}
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- 右 -->
                    <div class="layui-col-sm12 layui-col-md9">
                        <div class="layui-card">
                            <!-- 选项卡开始 -->
                            <div class="layui-tab layui-tab-brief" lay-filter="userInfoTab">
                                <ul class="layui-tab-title">
                                    <li class="layui-this">基本信息</li>
                                    <li>账号绑定</li>
                                </ul>
                                <div class="layui-tab-content">
                                    <!-- tab1 -->
                                    <div class="layui-tab-item layui-show">
                                        <form class="layui-form" id="userInfoForm" lay-filter="userInfoForm"
                                              style="max-width: 400px;padding: 25px 10px 0 0;">
                                            <input type="hidden" name="Id" value="{{d.Id}}" />
                                            <div class="layui-form-item">
                                                <label class="layui-form-label layui-form-required">邮箱:</label>
                                                <div class="layui-input-block">
                                                    <input name="Email" value="{{d.Email}}" class="layui-input"
                                                           lay-verify="required" required />
                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label layui-form-required">昵称:</label>
                                                <div class="layui-input-block">
                                                    <input name="RealName" value="{{d.RealName}}" class="layui-input"
                                                           lay-verify="required" required />
                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">个人简介:</label>
                                                <div class="layui-input-block">
                                                    <textarea name="Remark" class="layui-textarea">{{d.Remark}}</textarea>
                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">出生日期:</label>
                                                <div class="layui-input-block">
                                                    <input name="Birthday" id="Birthday" value="{{d.Birthday}}" class="layui-input" readonly />
                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">联系电话:</label>
                                                <div class="layui-input-block">
                                                    <input name="Mobile" value="{{d.Mobile}}" class="layui-input" />
                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <div class="layui-input-block">
                                                    <button class="layui-btn" lay-filter="userInfoSubmit" lay-submit>
                                                        更新基本信息
                                                    </button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                    <!-- tab1 -->
                                    <div class="layui-tab-item" style="padding-bottom: 20px;">
                                        <div class="user-bd-list layui-text">
                                            <div class="user-bd-list-item">
                                                <div class="user-bd-list-lable">密保手机</div>
                                                <div class="user-bd-list-text">已绑定手机：138****8293</div>
                                                <a class="user-bd-list-oper">修改</a>
                                            </div>
                                            <div class="user-bd-list-item">
                                                <div class="user-bd-list-lable">密保邮箱</div>
                                                <div class="user-bd-list-text">已绑定邮箱：easyweb@vip.com</div>
                                                <a class="user-bd-list-oper">修改</a>
                                            </div>
                                            <div class="user-bd-list-item">
                                                <div class="user-bd-list-img">
                                                    <i class="layui-icon layui-icon-login-qq"
                                                       style="color: #3492ED;font-size: 48px;"></i>
                                                </div>
                                                <div class="user-bd-list-content">
                                                    <div class="user-bd-list-lable">绑定QQ</div>
                                                    <div class="user-bd-list-text">当前未绑定QQ账号</div>
                                                </div>
                                                <a class="user-bd-list-oper">绑定</a>
                                            </div>
                                            <div class="user-bd-list-item">
                                                <div class="user-bd-list-img">
                                                    <i class="layui-icon layui-icon-login-wechat"
                                                       style="color: #4DAF29;font-size: 48px;"></i>
                                                </div>
                                                <div class="user-bd-list-content">
                                                    <div class="user-bd-list-lable">绑定微信</div>
                                                    <div class="user-bd-list-text">当前未绑定绑定微信账号</div>
                                                </div>
                                                <a class="user-bd-list-oper">绑定</a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!-- //选项卡结束 -->
                        </div>
                    </div>
                </div>
            </div>
        </script>
    </div>
    <!-- 初始加载动画 -->
    <div class="page-loading">
        <div class="signal-loader">
            <span></span><span></span><span></span><span></span>
        </div>
    </div>

    <!-- js部分 -->
    <script src="/assets/libs/jquery/jquery-3.2.1.min.js"></script>
    <script src="/assets/libs/layui/layui.js"></script>
    <script src="/assets/js/utils.js"></script>
    <script src="/assets/js/main.js"></script>
    <script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
    <script>
        layui.use(['layer', 'form', 'element', 'admin', 'setter', 'laydate'], function () {
            var $ = layui.jquery;
            var layer = layui.layer;
            var form = layui.form;
            var element = layui.element;
            var admin = layui.admin;
            var setter = layui.setter;
            var laydate = layui.laydate;

            laydate.render({
                elem: '#Birthday'
                , type: 'date'
                , trigger: 'click'
            });

            admin.req('/OrganizationManage/User/GetFormJson', { id: setter.getUser().UserId }, function (res) {
                admin.removeLoading();
                if (res.Tag == 1) {
                    window.userData = res.Data;
                    admin.renderTpl('#userDataTpl');

                    /* 选择头像 */
                    $('#userInfoHead').click(function () {
                        admin.cropImg({
                            imgSrc: $('#userInfoHead>img').attr('src'),
                            onCrop: function (res) {
                                var loadIndex = layer.load(2);
                                admin.req('/ToolManage/FileHelper/UploadImgFile', { FileModule: 1, ImgPath: res }, function (d) {
                                    if (d.Tag == 1) {
                                        admin.req('/OrganizationManage/User/UpdateBaseData', { id: setter.getUser().UserId, Portrait: d.Data }, function (d) {

                                            layer.close(loadIndex);

                                            if (d.Tag == 1) {
                                                layer.msg('上传成功', { icon: 1 });
                                                $('#userInfoHead>img').attr('src', res);
                                                parent.layui.jquery('.layui-layout-admin>.layui-header .layui-nav img.layui-nav-img').attr('src', res);
                                            } else {
                                                layer.msg(d.Message, { icon: 2 });
                                            }
                                        }, 'post');

                                    } else {
                                        layer.msg(d.Message, { icon: 2 });
                                    }
                                }, 'post');
                            }
                        });
                    });
                }
            }, 'get');


            /* 监听表单提交 */
            form.on('submit(userInfoSubmit)', function (data) {
                var loadIndex = layer.load(2);
                admin.req('/OrganizationManage/User/UpdateBaseData', data.field, function (d) {

                    layer.close(loadIndex);

                    if (d.Tag == 1) {
                        layer.msg('修改成功', { icon: 1 });
                    } else {
                        layer.msg(d.Message, { icon: 2 });
                    }
                }, 'post');
                return false;
            });

        });
    </script>
</body>
</html>